import { unbind_platform_list } from '@/services/instiution';
import { ActionType, PageContainer, ProColumns, ProTable } from '@ant-design/pro-components';
import { useRef } from 'react';
type GithubIssueItem = {
  url: string;
  id: number;
  number: number;
  title: string;
  labels: {
    name: string;
    color: string;
  }[];
  state: string;
  comments: number;
  created_at: string;
  updated_at: string;
  closed_at?: string;
};
const UnbindRecord = () => {
  const actionRef = useRef<ActionType>();
  // 获取解绑记录列表
  const get_unbind_platform_list = async (params: {
    pageSize?: number | undefined;
    current?: number | undefined;
    keyword?: string | undefined;
  }) => {
    //默认分页参数和后端接口字段不匹配
    let request_body = {
      ...params,
      current: params.current,
      pageSize: params.pageSize,
    };
    console.log(params);
    const res = await unbind_platform_list(request_body);
    // console.log('机构列表', res);
    return {
      data: res.data.list,
      success: true,
      total: res.data.total_count,
    };
  };
  // 解绑记录列表字段
  const columns: ProColumns<GithubIssueItem>[] = [
    {
      title: '序号',
      dataIndex: 'index',
      valueType: 'index',
      width: 48,
      align: 'center',
    },
    {
      title: '机构账号',
      dataIndex: 'phone',
      hideInSearch: true,
      align: 'center',
    },
    {
      title: '机构名称',
      dataIndex: 'name',
      hideInSearch: true,
      align: 'center',
    },
    {
      title: '机构编号',
      dataIndex: 'unique_code',
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '解绑人',
      dataIndex: 'manage_name',
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '解绑时间',
      key: 'unbind_time',
      dataIndex: 'unbind_time',
      align: 'center',
      hideInSearch: true,
    },
    {
      title: '解绑时间',
      dataIndex: 'unbind_time',
      valueType: 'dateRange',
      hideInTable: true,
      align: 'center',
      search: {
        transform: (value) => {
          return {
            start_date: value[0],
            end_date: value[1],
          };
        },
      },
    },
  ];
  return (
    <PageContainer breadcrumb={false}>
      <ProTable<GithubIssueItem>
        columns={columns}
        actionRef={actionRef}
        cardBordered
        request={async (params = {}) => get_unbind_platform_list(params)}
        editable={{
          type: 'multiple',
        }}
        rowKey={(record) => record.id}
        search={{
          labelWidth: 'auto',
          span: 6,
        }}
        options={{
          setting: {
            listsHeight: 400,
          },
        }}
        pagination={{
          pageSize: 10,
        }}
        dateFormatter="string"
        headerTitle="解绑记录列表"
      />
    </PageContainer>
  );
};
export default UnbindRecord;
